<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, ValidatesRequests;

    protected static function send($data = [], $code = 200, $message = "") {
        $data = [
            "data" => $data,
            "msg" => $message,
            "code" => $code
        ];
        return response()->json($data, 200);
    }

    protected static function sendError($message = "", $code = 400) {
        $data = [
            "data" => [],
            "code" => $code,
            "msg" => $message
        ]; 
        return response()->json($data, 200);
    }

    protected static function err($message = "", $code = 400) {
        return self::sendError($message, $code);
    }

    protected static function sendOk($data = [], $message = "success", $code = 200) {
        $data = [
            "data" => $data,
            "msg" => $message,
            "code" => $code
        ];
        return response()->json($data, 200);
    }

    protected static function ok($data = [], $message = "success", $code = 200) {
        return self::sendOk($data, $message, $code);
    }
}
